<template>
	<view style="background-color: #F6F6F6;">
		<view class="shiming">
			<view class="zuo">
				<h3>实名认证</h3>
				<view class="renzi" style="color: #C0C0C0;">
					上传身份证
				</view>
			</view>
			<view class="you" v-if="sta.rStatus==null">
				<button class="button" @click="sm()">待认证</button>
			</view>
			<view class="you" v-if="sta.rStatus==0">
				<button class="button" disabled="false">待审核</button>
			</view>
			<view class="you" v-if="sta.rStatus==1">
				<button class="button" disabled="false">已通过</button>
			</view>
			<view class="you" v-if="sta.rStatus==2">
				<button class="button" @click="chel()">未通过</button>
			</view>
		</view>
		<view class="shiming">
			<view class="zuo">
				<h3>车辆认证</h3>
				<view class="renzi" style="color: #C0C0C0;">
					需上传车辆行驶证，益路运输证，运营许可证
				</view>
			</view>
			<view class="you" v-if="sta.carStatus==null">
				<button class="button" @click="chel()">待认证</button>
			</view>
			<view class="you" v-if="sta.carStatus==0">
				<button class="button" disabled="false">待审核</button>
			</view>
			<view class="you" v-if="sta.carStatus==1">
				<button class="button" disabled="false">已通过</button>
			</view>
			<view class="you" v-if="sta.carStatus==2">
				<button class="button" @click="chel()">未通过</button>
			</view>
		</view>
		<view class="tishi">
			如存在车主兼职司机的情况，需认证一下证件
		</view>
		<view class="shiming">
			<view class="zuo">
				<h3>驾驶证认证</h3>
				<view class="renzi" style="color: #C0C0C0;">
					需上传驾驶证，益路运输从业资格证
				</view>
			</view>
			<view class="you" v-if="sta.dStatus==null">
				<button class="button" @click="jsz()">待认证</button>
			</view>
			<view class="you" v-if="sta.dStatus==0">
				<button class="button" disabled="false">待审核</button>
			</view>
			<view class="you" v-if="sta.dStatus==1">
				<button class="button" disabled="false">已通过</button>
			</view>
			<view class="you" v-if="sta.dStatus==2">
				<button class="button" @click="chel()">未通过</button>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,onMounted
	} from 'vue'
	//引入存放jwt的容器
	import {
		tokenStore
	} from '@/stores/token';
	//存放用户信息的容器
	import {
		userStore
	} from '@/stores/user';
	//引入拦截器
	import '@/config/requst.js'
	import {
		http
	} from '@/config/requst.js';
	const sta = ref({})
	const id = ref()
	const sm = () => {
		uni.navigateTo({
			url: '/pages/driverAuthentication/driverAuthentication'
		})
	}
	const chel = () => {
		uni.navigateTo({
			url: '/pages/carPage/carPage'
		})
	}
	const jsz = () => {
		uni.navigateTo({
			url: '/pages/driveAndrun/driveAndrun'
		})
	}
	//查询该用户的审核状态
	const cha = async () => {
		const res = await http({
			url: '/realname/select/'+id.value,

		})
		sta.value = res.shuju
		console.log(sta.value)
		if(sta.value.carStatus == 1 && sta.value.rStatus == 1 && sta.value.dStatus == 1){
			uni.showToast({
				title: '恭喜您，所有审核都通过了',
				icon: 'success',
				duration: 2000
			});
			setTimeout(() => {
				uni.switchTab({
					url: '/pages/Search/Search'
				});
			}, 2000);
		}
	}
	onMounted(() =>{
		const token = tokenStore().token
		id.value = userStore().user.id
		cha()
	})
</script>

<style>
	.button {
		font-size: 26rpx;
		width: 150rpx;
		border-radius: 50rpx;
		margin-right: 30rpx;

	}

	.shiming {
		display: flex;
		padding-bottom: 30rpx;
		padding-top: 20rpx;
		padding-left: 40rpx;
		background-color: #FFFFFF;
		margin-top: 20rpx;
	}

	.you {
		position: absolute;
		right: 10rpx;
	}

	.tishi {
		color: #D09866;
		margin-top: 50rpx;
		padding-left: 40rpx;
	}

	.renzi {
		/* border: 1px solid #000; */
		height: 50rpx;
		line-height: 50rpx;
		font-size: 22rpx;
	}
</style>